<!DOCTYPE html>
<html>

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />

<head>
    <meta charset="utf-8">
    <title>layuiAdmin 后台管理员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/public.css">

</head>

<body>
    <div class="layui-card layui-wh100">
        <div class="layui-card-body">
            <div class="layui-form">
                <div class="layui-form-item">
                    角色：
                </div>
                <div class="layui-form-item">
                    <input style="width: 230px;" type="text" name="H1" lay-verify="H1" autocomplete="off"
                        placeholder="请输入角色名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <button style="background-color:black" class="layui-btn layui-col-md-offset4" id="savaChange"
                        lay-submit="" lay-filter="savaChange">立即提交</button>
                </div>
            </div>
        </div>
    </div>

    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index', //主入口模块
            _role: 'lib/_role'
        }).use(['_role', 'utilJs', 'form'], function (option) {
            var _role = layui._role,
                $ = layui.$,
                form = layui.form,
                utilJs = layui.utilJs;
            //自定义验证规则
            form.verify({
                H1: function (value) {
                    if (value.length == 0) {
                        return '角色名不能为空';
                    }
                },
            });
            form.on('submit(savaChange)',r=>{
                _role.add_role(r.field).then(r=>{
                    utilJs.admin.topMsg('新增角色成功',()=>{
                        localStorage.setItem('guid', 1);
                        utilJs.admin.killIframe()
                    })
                })
            })
        })
    </script>
</body>

</html>
<style>

</style>